package spe.ui.editor.part;

import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPartFactory;

import spe.model.notation.Link;
import spe.model.notation.SPEMDiagram;
import spe.model.spem.NodeElement;

/*
 *	Author: Dao Anh Vu 
 * 	The class is used to create appropriate edit part based on 
 *  type of model
 * */

public class GraphicalEditPartFactory implements EditPartFactory
{
	@Override
	public EditPart createEditPart(EditPart arg0, Object model) 
	{	
		if(model instanceof SPEMDiagram)
		{
			//System.out.println("GraphicalEditPartFactory GraphEditPart");
			return (new GraphEditPart((SPEMDiagram)model));
		}
		
		/*
		if(model instanceof MethodPlugin)
		{
			return (new MethodPluginEditPart((MethodPlugin)model));
		}
		
		if(model instanceof MethodContentPackage)
			return (new MethodContentPackageEditPart((MethodContentPackage)model));
		
		if(model instanceof ProcessPackage)
			return (new ProcessPackageEditPart((ProcessPackage)model));
		
		if(model instanceof TaskDefinition)
			return new TaskEditPart((TaskDefinition)model);
		
		if(model instanceof RoleDefinition)
			return new RoleEditPart((RoleDefinition)model);
		
		if(model instanceof WorkProductDefinition)
			return new WorkProductDefEditPart((WorkProductDefinition)model);
		*/
		
		if(model instanceof Link)
			return (new LinkEditPart((Link)model));
		
		if(NodeElement.class.isInstance(model))
			return new NodeElementEditPart((NodeElement) model);
		
		return null;
	}
	
}